package com.linedata.acq.metier.norme.fmb;

import oracle.forms.jdapi.Block;
import oracle.forms.jdapi.FormModule;
import oracle.forms.jdapi.Item;
import oracle.forms.jdapi.JdapiIterator;

public class GBUT_FMB {

	private FormModule	fmb;

	public GBUT_FMB(FormModule fmb) {
		this.fmb = fmb;
	}

	private String	error	= "";

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error += error;
	}

	/**
	 * EKFR011_1 :: Le nom des boutons (Autres que ZOOM et LOV) est
	 * PB_ « verbe à l'infinitif »
	 * 
	 * @param fmb
	 */
	public void nomBouton() {

		for (JdapiIterator blocks = fmb.getBlocks(); blocks.hasNext();) {

			Block block = (Block) blocks.next();
			for (JdapiIterator items = block.getItems(); items.hasNext();) {

				Item item = (Item) items.next();
				if (item.getItemType() == 7 && item.isSubclassed()
						&& !item.getSubclassParent().getName().equals("IESO$BUTTON_EDIT")
						&& !item.getSubclassParent().getName().equals("IESO$LOV_BUT")
						&& !item.getSubclassParent().getName().equals("IESO$LOV_BUT_MR")
						&& !item.getName().startsWith("PB_")) {

					this.setError("\tEKFR011_1 : " + block.getName() + "\t::  " + item.getName() + "\n");
				}
			}
		}
	}

	@Override
	public String toString() {
		return this.getError();
	}
}
